<HTML>
<HEAD>
<!-- Created by texi2html 1.56k from abs_integrate.texi on 4 February 2009 -->

<TITLE>Untitled Document</TITLE>
</HEAD>
<BODY>
<H1>Untitled Document</H1>
<P>
<P><HR><P>

<P>
The package <CODE>abs_integrate</CODE> extends Maxima's integration code to
some integrands that involve the absolute value, max, min, signum, or
unit step functions. For integrands of the form <EM>p(x) |q(x)|</EM>,
where <EM>p</EM> is a polynomial and <EM>q</EM> is a polynomial that
<CODE>factor</CODE> is able to factor into a product of linear or constant
terms, the <CODE>abs_integrate</CODE> package determines an antiderivative
that is continuous on the entire real line.


<P>
<B>Examples</B> To use the <CODE>abs_integrate</CODE> package, you'll first need to load it:

<PRE>
 (%i1) load("abs_integrate.mac")$

 (%i2)  integrate(abs(x),x);
 (%o2) (x^2*signum(x))/2
</PRE>

<P>
To convert (%o2) into an expression involving the absolute value function,
apply <CODE>signum_to_abs</CODE>; thus

<PRE>
 (%i3) signum_to_abs(%);
 (%o3) (x*abs(x))/2
</PRE>

<P>
When the integrand has the form <EM>p(x) |x - c1| |x - c2| ... |x - cn|</EM>,
where <EM>p(x)</EM> is a polynomial and <EM>c1, c2, ..., cn</EM> are constants,
the <CODE>abs_integrate</CODE> package returns an antiderivative that is valid on the
entire real line; thus <I>without</I> making assumptions on <EM>a</EM> and <EM>b</EM>;
for example

<PRE>
 (%i4) factor(convert_to_signum(integrate(abs((x-a)*(x-b)),x,a,b)));
 (%o4) ((b-a)^3*signum(b-a)^2)/6
</PRE>

<P>
Additionally, <CODE>abs_integrate</CODE> is able to find antiderivatives of some
integrands involving <CODE>max, min, signum</CODE>, and <CODE>unit_step</CODE>;
examples:

<PRE>
 (%i5) integrate(max(x,x^2),x);
 (%o5) signum(x-1)*((x^3*signum(x))/6-1/6)+signum(x-1)*(1/4-(x^2*signum(x))/4)+x^3/6+x^2/4

 (%i6) integrate(signum(x) - signum(1-x),x);
 (%o6) x*signum(x)+(x-1)*signum(x-1)
</PRE>

<P>
A plot indicates that indeed (%o5) and (%o6) are continuous at zero and at one.


<P>
For definite integrals with numerical integration limits (including
both minus and plus infinity), the <CODE>abs_integrate</CODE> package
converts the integrand to signum form and then it tries to subdivide
the integration region so that the integrand simplifies to a
non-signum expression on each subinterval; for example

<PRE>
 (%i1) integrate(1 / (1 + abs(x-5)),x,-5,6);
 (%o1) log(11)+log(2)
</PRE>

<P>
Finally, <CODE>abs_integrate</CODE> is able to determine antiderivatives of <EM>some</EM>
functions of the form <EM>F(x, |x - a|)</EM>; examples

<PRE>
 (%i2) integrate(1/(1 + abs(x)),x);
 (%o2) ((signum(x)+1)*log(x+1))/2-(log(1-x)*(1-signum(x)))/2

 (%i3) integrate(cos(x + abs(x)),x);
 (%o3) ((signum(x)+1)*sin(2*x)-2*x*signum(x)+2*x)/4
</PRE>

<P>
Barton Willis (Professor of Mathematics, University of Nebraska at
Kearney) wrote the <CODE>abs_integrate</CODE> package and its English
language user documentation. This documentation also describes the
<CODE>partition</CODE> package for integration. Richard Fateman wrote
<CODE>partition</CODE>. Additional documentation for <CODE>partition</CODE> is
located at http://www.cs.berkeley.edu/~fateman/papers/partition.pdf.


<P>
<B>To use</B> <TT>`load(abs_integrate)'</TT>


<P>
<DL>
<DT><U>Option:</U> <B>extra_integration_methods</B>
<DD><A NAME="IDX1"></A>
Default value: <CODE>['signum_int, 'abs_integrate_use_if]</CODE>


<P>
The list <CODE>extra_integration_methods</CODE> is a list of functions for
integration. When <CODE>integrate</CODE> is unable to find an
antiderivative, Maxima uses the methods in
<CODE>extra_integration_methods</CODE> to attempt to determine an
antiderivative.


<P>
Each function <CODE>f</CODE> in <CODE>extra_integration_methods</CODE> should have
the form <CODE>f(integrand, variable)</CODE>. The function <CODE>f</CODE> may
either return <CODE>false</CODE> to indicate failure, or it may return an
expression involving an integration noun form. The integration methods
are tried from the first to the last member of
<CODE>extra_integration_methods</CODE>; when no method returns an expression
that does not involve an integration noun form, the value of the
integral is the last value that does not fail (or a pure noun form if
all methods fail).


<P>
When the function <CODE>abs_integrate_use_if</CODE> is successful, it returns
a conditional expression; for example

<PRE>
 (%i2) integrate(1/(1 + abs(x+1) + abs(x-1)),x);
 (%o2) %if(-(x+1)&#62;0,-log(1-2*x)/2+log(3)-2/3,%if(-(x-1)&#62;0,x/3+log(3)/2-1/3,log(2*x+1)/2))

 (%i3) integrate(exp(-abs(x-1) - abs(x)),x);
 (%o3) %if(-x&#62;0,%e^(2*x-1)/2-2*%e^(-1),%if(-(x-1)&#62;0,%e^(-1)*x-(3*%e^(-1))/2,-%e^(1-2*x)/2))
</PRE>

<P>
For definite integration, these conditional expressions can cause trouble:

<PRE>
 (%i4) integrate(exp(-abs(x-1) - abs(x)),x, minf,inf);
 (%o4) limit(%if(-x&#62;0,(%e^(-1)*(%e^(2*x)-4))/2,%if(-(x-1)&#62;0,(%e^(-1)*(2*x-3))/2,-%e^(1-2*x)/2)),x,inf,minus)-limit(%if(-x&#62;0,(%e^(-1)*(%e^(2*x)-4))/2,%if(-(x-1)&#62;0,(%e^(-1)*(2*x-3))/2,-%e^(1-2*x)/2)),x,-inf,plus)
</PRE>

<P>
For such definite integrals, try disallowing the method <CODE>abs_integrate_use_if</CODE>:

<PRE>
(%i9) integrate(exp(-abs(x-1) - abs(x)),x, minf,inf), extra_integration_methods : ['signum_int];
(%o9) 2*%e^(-1)
</PRE>

<P>
<B>Related options</B> <I>extra_definite_integration_methods</I>


<P>
<B>To use</B> <TT>`load(abs_integrate)'</TT>


</DL>

<P>
<DL>
<DT><U>Option:</U> <B>extra_definite_integration_methods</B>
<DD><A NAME="IDX2"></A>
Default value: <CODE>['abs_defint]</CODE>


<P>
The list <CODE>extra_definite_integration_methods</CODE> is a list of extra
functions for <I>definite</I> integration.  When <CODE>integrate</CODE> is
unable to find a definite integral, Maxima uses the methods in
<CODE>extra_definite_integration_methods</CODE> to attempt to determine an
antiderivative.


<P>
Each function <CODE>f</CODE> in <CODE>extra_definite_integration_methods</CODE>
should have the form <CODE>f(integrand, variable, lo, hi)</CODE>, where
<CODE>lo</CODE> and <CODE>hi</CODE> are the lower and upper limits of integration,
respectively.  The function <CODE>f</CODE> may either return <CODE>false</CODE> to
indicate failure, or it may return an expression involving an
integration noun form. The integration methods are tried from the
first to the last member of <CODE>extra_definite_integration_methods</CODE>;
when no method returns an expression that does not involve an
integration noun form, the value of the integral is the last value
that does not fail (or a pure noun form if all methods fail).


<P>
<B>Related options</B> <I>extra_integration_methods</I>


<P>
<B>To use</B> <TT>`load(abs_integrate)'</TT>


</DL>

<P>
<DL>
<DT><U>Function:</U> <B>intfudu(<VAR>e</VAR>,</B> <I><VAR>x</VAR>)</I>
<DD><A NAME="IDX3"></A>


<P>
This function uses the derivative divides rule for integrands of the
form <EM>f(w(x)) * diff(w(x),x)</EM> When <CODE>infudu</CODE> is unable to find
an antiderivative, it returns false.



<PRE>
(%i1) intfudu(cos(x^2) * x,x);
(%o1) sin(x^2)/2

(%i3) intfudu(x * sqrt(1+x^2),x);
(%o3) (x^2+1)^(3/2)/3

(%i4) intfudu(x * sqrt(1 + x^4),x);
(%o4) false
</PRE>

<P>
For the last example, the derivative divides rule fails, so
<CODE>intfudu</CODE> returns false. 


<P>
A hashed array <CODE>intable</CODE> contains the antiderivative data. To append a fact
to the hash table, say <EM>integrate(f) = g</EM>, do this:



<PRE>
(%i1) intable[f] : lambda([u],  [g(u),diff(u,%voi)]);
(%o1) lambda([u],[g(u),diff(u,%voi)])

(%i2) intfudu(f(z),z);
(%o2) g(z)

(%i3) intfudu(f(w(x)) * diff(w(x),x),x);
(%o3) g(w(x))
</PRE>

<P>
An alternative to calling <CODE>intfudu</CODE> directly is to use the <CODE>extra_integration_methods</CODE>
mechanism; an example:

<PRE>
(%i1) load("abs_integrate.mac")$
(%i2) load(basic)$
(%i3) load("partition.mac")$

(%i4) integrate(bessel_j(1,x^2) * x,x);
(%o4) integrate(bessel_j(1,x^2)*x,x)

(%i5) push('intfudu, extra_integration_methods)$

(%i6) integrate(bessel_j(1,x^2) * x,x);
(%o6) -bessel_j(0,x^2)/2
</PRE>

<P>
<B>To use</B> <TT>`load(partition)'</TT>


<P>
<B>Additional documentation</B> http://www.cs.berkeley.edu/~fateman/papers/partition.pdf


<P>
<B>Related functions</B> <I>intfugudu</I>


</DL>

<P>
<DL>
<DT><U>Function:</U> <B>intfugudu</B> <I>(<VAR>e</VAR>, <VAR>x</VAR>)</I>
<DD><A NAME="IDX4"></A>


<P>
This function uses the derivative divides rule for integrands of the
form <EM>f(w(x)) * g(w(x)) * diff(w(x),x)</EM>. When <CODE>infudu</CODE> is
unable to find an antiderivative, it returns false. 



<PRE>
(%i1) diff(jacobi_sn(x,2/3),x);
(%o1) jacobi_cn(x,2/3)*jacobi_dn(x,2/3)

(%i2) intfugudu(%,x);
(%o2) jacobi_sn(x,2/3)

(%i3) diff(jacobi_dn(x^2,a),x);
(%o3) -2*a*x*jacobi_cn(x^2,a)*jacobi_sn(x^2,a)

(%i4) intfugudu(%,x);
(%o4) jacobi_dn(x^2,a)
</PRE>

<P>
For a method for automatically calling <CODE>infugudu</CODE> from <CODE>integrate</CODE>, see
the documentation for <CODE>intfudu</CODE>.


<P>
<B>To use</B> <TT>`load(partition)'</TT>


<P>
<B>Additional documentation</B> http://www.cs.berkeley.edu/~fateman/papers/partition.pdf


<P>
<B>Related functions</B> <I>intfudu</I>


</DL>

<P>
<DL>
<DT><U>Function:</U> <B>signum_to_abs</B> <I>(<VAR>e</VAR>)</I>
<DD><A NAME="IDX5"></A>
 
This function replaces subexpressions of the form <EM>q signum(q)</EM> by
<EM>abs(q)</EM>.  Before it does these substitutions, it replaces
subexpressions of the form <EM>signum(p) * signum(q)</EM> by
<EM>signum(p * q)</EM>; examples:



<PRE>
 (%i1) map('signum_to_abs, [x * signum(x), x * y * signum(x)* signum(y)/2]);
 (%o1) [abs(x),(abs(x)*abs(y))/2]
</PRE>

<P>
<B>To use</B> <TT>`load(abs_integrate)'</TT>


</DL>

<P>
<DL>
<DT><U>Macro:</U> <B>simp_assuming</B> <I>(<VAR>e</VAR>, <VAR>f_1</VAR>, <VAR>f_2</VAR>, ..., <VAR>f_n</VAR>)</I>
<DD><A NAME="IDX6"></A>


<P>
Appended the facts <EM>f_1, f_2, ..., f_n</EM> to the current context and simplify
<EM>e</EM>. The facts are removed before returning the simplified expression <EM>e</EM>.



<PRE>
(%i2) simp_assuming(x + abs(x), x &#60; 0);
(%o2) 0
</PRE>

<P>
The facts in the current context aren't ignored:

<PRE>
(%i3) assume(x &#62; 0)$
(%i4) simp_assuming(x + abs(x),x &#60; 0);
(%o4) 2*x
</PRE>

<P>
Since <CODE>simp_assuming</CODE> is a macro, effectively <CODE>simp_assuming</CODE> quotes is arguments;
this allows

<PRE>
(%i5) simp_assuming(asksign(p), p &#60; 0);
(%o5) neg
</PRE>

<P>
<B>To use</B> <TT>`load(abs_integrate)'</TT>


</DL>

<P>
<DL>
<DT><U>Function:</U> <B>convert_to_signum</B> <I>(<VAR>e</VAR>)</I>
<DD><A NAME="IDX7"></A>


<P>
This function replaces subexpressions of the form <EM>abs(q), unit_step(q),
 min(q1,q2, ..., qn)</EM> and <EM>max(q1,q2, ..., qn)</EM> by equivalent <EM>signum</EM>
terms.



<PRE>
 (%i1) map('convert_to_signum, [abs(x), unit_step(x), max(a,2), min(a,2)]);
 (%o1) [x*signum(x),(signum(x)+1)/2,((a-2)*signum(a-2)+a+2)/2,(-(a-2)*signum(a-2)+a+2)/2]
</PRE>

<P>
To convert <CODE>unit_step</CODE> to signum form, the function <CODE>convert_to_signum</CODE> 
uses <EM>unit_step(x) = (1 + signum(x))/2</EM>. 


<P>
<B>To use</B> <TT>`load(abs_integrate)'</TT>


<P>
<B>Related functions</B> <I>signum_to_abs</I>


</DL>

<P>
<DL>
<DT><U>Function:</U> <B>make_dummy(e,x)</B>
<DD><A NAME="IDX8"></A>


<P>
Append "%" to the symbol <EM>x</EM> until <EM>x</EM> is <I>not</I> a variable in the expression <EM>e</EM>.



<PRE>
 (%i1) make_dummy((x-y)*x, x);
 (%o1) x%

 (%i2) make_dummy((x-y)*x%, x);
 (%o2) x%%
</PRE>

<P>
<B>To use</B> <TT>`load(abs_integrate)'</TT>


</DL>
<P><HR><P>
This document was generated on 4 February 2009 using
<A HREF="http://wwwinfo.cern.ch/dis/texi2html/">texi2html</A>&nbsp;1.56k.
</BODY>
</HTML>
